﻿using System;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework;
using NHibernate;

namespace BusinessModels
{
    //public class QueryTest : ActiveRecordBaseQuery
    //{
    //    private String authorName = null;
    //    private int maxResults = 2;

    //    public QueryTest()
    //        : base(typeof(Movie))
    //    {
    //    }

    //    public QueryTest(string authorName)
    //        : base(typeof(Movie))
    //    {
    //        this.AuthorName = authorName;
    //    }

    //    public int MaxResults { get { return this.maxResults; } set { this.maxResults = value; } }
    //    public String AuthorName { get { return this.authorName; } set { this.authorName = value; } }

    //    protected override IQuery CreateQuery(ISession session)
    //    {
    //        String hql = "from Movie b";

    //        if (this.AuthorName != null)
    //            hql += " where b.Name like :author";

    //        IQuery q = session.CreateQuery(hql);

    //        if (AuthorName != null)
    //            q.SetString("authorName", this.AuthorName);

    //        q.SetMaxResults(this.MaxResults);

    //        return q;
    //    }

    //    protected override object InternalExecute(ISession session)
    //    {
    //        IQuery q = CreateQuery(session);
    //        return SupportingUtils.BuildArray(typeof(Movie), q.List(), 0, false);
    //    }
    //}
}
